package org.dromara.system.domain.bo;

import cn.hutool.core.bean.BeanUtil;
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
import org.dromara.system.domain.SysStore;
import org.dromara.common.mybatis.core.domain.BaseEntity;
import org.dromara.common.core.validate.AddGroup;
import org.dromara.common.core.validate.EditGroup;
import lombok.Data;
import lombok.EqualsAndHashCode;
import jakarta.validation.constraints.*;
import java.math.BigDecimal;
import java.util.List;
import java.util.StringJoiner;

/**
 * 系统管理-门店配置业务对象 sys_store
 *
 * @author LionLi
 * @date 2024-03-18
 */
@Data
@EqualsAndHashCode(callSuper = true)
//@AutoMapper(target = SysStore.class, reverseConvertGenerate = false)
public class SysStoreBo extends BaseEntity {

    /**
     * 门店id
     */
    @NotNull(message = "门店id不能为空", groups = { EditGroup.class })
    private Long storeId;

    /**
     * 区域id（sys_area表所在区域id）
     */
    @NotNull(message = "区域id（sys_area表所在区域id）不能为空", groups = { AddGroup.class, EditGroup.class })
    private Long groupId;

    /**
     * 区域id和区域祖级列表（如：区域id，区域祖级列表）
     */
//  @NotEmpty(message = "区域id和区域祖级列表（如：区域id，区域祖级列表）不能为空", groups = { AddGroup.class, EditGroup.class })
    private List<String> groupIds;

    /**
     * 门店名称
     */
    @NotBlank(message = "门店名称不能为空", groups = { AddGroup.class, EditGroup.class })
    private String storeName;

    /**
     * 行政区域编码（如：420102）
     */
    @NotNull(message = "行政区域编码（如：420102）不能为空", groups = { AddGroup.class, EditGroup.class })
    private Long areaId;

    /**
     * 所在省（如：湖北省）
     */
    @NotBlank(message = "所在省（如：湖北省）不能为空", groups = { AddGroup.class, EditGroup.class })
    private String province;

    /**
     * 所在市（如：武汉市）
     */
    @NotBlank(message = "所在市（如：武汉市）不能为空", groups = { AddGroup.class, EditGroup.class })
    private String city;

    /**
     * 经度（自动填充，在线地图选点）
     */
    @NotNull(message = "经度（自动填充，在线地图选点）不能为空", groups = { AddGroup.class, EditGroup.class })
    private BigDecimal longitude;

    /**
     * 维度（自动填充，在线地图选点）
     */
    @NotNull(message = "维度（自动填充，在线地图选点）不能为空", groups = { AddGroup.class, EditGroup.class })
    private BigDecimal latitude;

    /**
     * 门店编号（用户输入）
     */
    @NotBlank(message = "门店编号（用户输入）不能为空", groups = { AddGroup.class, EditGroup.class })
    private String storeCode;

    /**
     * 门店联系人(sys_user用户id)
     */
    private Long storeManagerId;

    /**
     * 门店联系人电话
     */
    private String contactMobile;

    /**
     * 门店状态（字典表：IN_BUSINESS运行 SUSPEND暂停 CLOSING关闭）
     */
    @NotBlank(message = "门店状态（字典表：IN_BUSINESS运行 SUSPEND暂停 CLOSING关闭）不能为空", groups = { AddGroup.class, EditGroup.class })
    private String storeStatus;

    /**
     * 门店营业时间（EVERYDAY每天，MON 每周一，WED 每周二，TUE 每周三，FRI 每周五，SAT 每周六，SUN 每周日，THU 每周四）如：[{"loopType":  [ "FRI","SAT","SUN","THU"],"duration":  [{ "start": "10:00", "end":  "22:00"}]}]
     */
    //[{"loopType":  [ "FRI","SAT","SUN","THU"],"duration":  [{ "start": "10:00", "end":  "22:00"}]}]
//    @NotEmpty(message = "门店营业时间（EVERYDAY每天，MON 每周一，WED 每周二，TUE 每周三，FRI 每周五，SAT 每周六，SUN 每周日，THU 每周四)不能为空", groups = { AddGroup.class, EditGroup.class })
    private Object  businessTimeInfo;

    /**
     * 门店面积（用户输入）
     */
    private Long storeArea;

    /**
     * 门店地址（用户输入）
     */
    @NotBlank(message = "门店地址（用户输入）不能为空", groups = { AddGroup.class, EditGroup.class })
    private String detailAddress;

    /**
     * 门店所在位置（自动填充，通过地图定位自动带入，如：湖北省武汉市江岸区三阳路128-130号三阳广场-A座）
     */
    @NotBlank(message = "门店所在位置（自动填充，通过地图定位自动带入，如：湖北省武汉市江岸区三阳路128-130号三阳广场-A座）不能为空", groups = { AddGroup.class, EditGroup.class })
    private String address;

    /**
     * 门店所在商场id（下拉列表选择，商场表id）
     */
    private Long shoppingMallId;

    private List<String>  storeLabels;

    private String groupIdStr;
    /**
     * 有无设备
     */
    private Boolean isDevice;

    private List<Long> storeIds;


    private String  statusNot;

    private Long userId;

    public String getStatusNot() {
        return statusNot;
    }

    public void setStatusNot(String statusNot) {
        this.statusNot = statusNot;
    }

    public List<Long> getStoreIds() {
        return storeIds;
    }

    public void setStoreIds(List<Long> storeIds) {
        this.storeIds = storeIds;
    }

    public Boolean getDevice() {
        return isDevice;
    }

    public void setDevice(Boolean device) {
        isDevice = device;
    }

    public String getGroupIdStr() {
        return groupIdStr;
    }

    public void setGroupIdStr(String groupIdStr) {
        this.groupIdStr = groupIdStr;
    }

    public SysStore toConvert(SysStoreBo bo) {
        SysStore sysStore = new SysStore();
        BeanUtil.copyProperties(bo, sysStore);
        return sysStore;
    }

    public Long getStoreId() {
        return storeId;
    }

    public void setStoreId(Long storeId) {
        this.storeId = storeId;
    }

    public Long getGroupId() {
        return groupId;
    }

    public void setGroupId(Long groupId) {
        this.groupId = groupId;
    }

    public String getGroupIds() {
        List<String> groupIds = this.groupIds;
        if (CollectionUtils.isEmpty(groupIds)) {
           return "";
        }
        StringJoiner joiner = new StringJoiner(",");
        groupIds.forEach(joiner::add);
        return joiner.toString();
    }

    public void setGroupIds(List<String> groupIds) {
        this.groupIds = groupIds;
    }

    public String getStoreName() {
        return storeName;
    }

    public void setStoreName(String storeName) {
        this.storeName = storeName;
    }

    public Long getAreaId() {
        return areaId;
    }

    public void setAreaId(Long areaId) {
        this.areaId = areaId;
    }

    public String getProvince() {
        return province;
    }

    public void setProvince(String province) {
        this.province = province;
    }

    public String getCity() {
        return city;
    }

    public void setCity(String city) {
        this.city = city;
    }

    public BigDecimal getLongitude() {
        return longitude;
    }

    public void setLongitude(BigDecimal longitude) {
        this.longitude = longitude;
    }

    public BigDecimal getLatitude() {
        return latitude;
    }

    public void setLatitude(BigDecimal latitude) {
        this.latitude = latitude;
    }

    public String getStoreCode() {
        return storeCode;
    }

    public void setStoreCode(String storeCode) {
        this.storeCode = storeCode;
    }

    public Long getStoreManagerId() {
        return storeManagerId;
    }

    public void setStoreManagerId(Long storeManagerId) {
        this.storeManagerId = storeManagerId;
    }

    public String getContactMobile() {
        return contactMobile;
    }

    public void setContactMobile(String contactMobile) {
        this.contactMobile = contactMobile;
    }

    public String getStoreStatus() {
        return storeStatus;
    }

    public void setStoreStatus(String storeStatus) {
        this.storeStatus = storeStatus;
    }


    public Object getBusinessTimeInfo() {
        return businessTimeInfo;
    }

    public void setBusinessTimeInfo(Object businessTimeInfo) {
        this.businessTimeInfo = businessTimeInfo;
    }

    public Long getStoreArea() {
        return storeArea;
    }

    public void setStoreArea(Long storeArea) {
        this.storeArea = storeArea;
    }

    public String getDetailAddress() {
        return detailAddress;
    }

    public void setDetailAddress(String detailAddress) {
        this.detailAddress = detailAddress;
    }

    public String getAddress() {
        return address;
    }

    public void setAddress(String address) {
        this.address = address;
    }

    public Long getShoppingMallId() {
        return shoppingMallId;
    }

    public void setShoppingMallId(Long shoppingMallId) {
        this.shoppingMallId = shoppingMallId;
    }

    public List<String> getStoreLabels() {
        return storeLabels;
    }

    public void setStoreLabels(List<String> storeLabels) {
        this.storeLabels = storeLabels;
    }
}
